package zero.tech.games.logic.timer;

import java.util.Map;

import org.springframework.context.annotation.Configuration;

import zero.tech.core.work.WorkManager;
import zero.tech.games.common.ThreadRunner;
import zero.tech.games.logic.common.CacheRoom;
import zero.tech.games.logic.common.Room;
import zero.tech.games.logic.work.room.RoomTimerWork;

@Configuration
public class Timer extends ThreadRunner{

	@Override
	public void process() {
		while(true) {
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			Map<String, Room> map=CacheRoom.getCache().getRooms();
//			System.out.println("当前房间数量:"+map.size());
			for(Room room:map.values()) {
				WorkManager.getManager().submit(RoomTimerWork.class,room);
			}
		}
	}

}
